exports.feedbackLists = (req, res) => {

    var restfulParams = req.routeInfo.restfulParams;

    var resultData = {};

    var u_id = restfulParams.u_id;

    var is_manager = restfulParams.is_manager;//是否是管理 0-否 1-是

    var skip = restfulParams.skip == undefined ? 0 : restfulParams.skip;

    var limit = restfulParams.limit == undefined ? 10000 : restfulParams.limit;

    var u_type = restfulParams.u_type;

    var u_osid = restfulParams.u_osid;

    var sqReplyUidCondition = '';

    var salesArr = [];

    var userInStr = "";

    //查询员工
    function salesSearch(cb) {
        if (is_manager == 1 && (u_type == 1 || u_type == 2)) {

            //战略  查询战略伙伴下所有销售
            console.log("战略 || 代理");
            console.log(CORE_APIConfig.coreAPI.userSearch.Request_Api_Url + "/u_master_osid/" + u_osid)
            R.SEND_HTTP(
                req,
                res, {
                    url: CORE_APIConfig.coreAPI.userSearch.Request_Api_Url + "/u_master_osid/" + u_osid,
                    method: 'POST',
                    data: {
                        fields: ['u_id'].join(",")
                    }
                },
                function (data) {

                    salesArr = data.result.data;

                    cb();

                }
            )
        } else if (is_manager == 1 && u_type == 3) {
            //销售主管  查询该销售主管下所有销售.包括自己。
            console.log("销售组长");
            R.SEND_HTTP(
                req,
                res, {
                    url: CORE_APIConfig.coreAPI.userSearch.Request_Api_Url + "/u_leader/" + restfulParams.u_id,
                    method: 'POST',
                    data: {
                        fields: ['u_id'].join(",")
                    }
                },
                function (data) {

                    salesArr = data.result.data;

                    cb();

                }
            )
        } else if (is_manager == 0 && u_type == 3) {
            //普通销售
            console.log("普通销售");
            salesArr.push({
                u_id: u_id
            });
            cb();
        } else if (u_type == 0) {
            //超管
            console.log("超管");
            R.SEND_HTTP(
                req,
                res, {
                    url: CORE_APIConfig.coreAPI.userSearch.Request_Api_Url,
                    method: 'POST',
                    data: {
                        fields: ['u_id'].join(",")
                    }
                },
                function (data) {

                    salesArr = data.result.data;
                    cb();

                }
            )
        }
    }

    // 拼接in语句查询条件
    function fixInCondition(cb) {
        for (var i = 0; i < salesArr.length; i++) {
            userInStr += salesArr[i].u_id + ","
        }
        userInStr = userInStr.substring(0, userInStr.length - 1);
        if(userInStr == ''){
            userInStr = "null";
        }
        if (u_type > 0) {
            sqReplyUidCondition = "/in/sq_reply_uid-" + userInStr;
        }

        cb()
    }


    //查询待处理异议信息
    function waitingDealFeedbackInfo(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.artSalesQuestionSearch.Request_Api_Url + "/sq_is_delete/0/" + sqReplyUidCondition + "/sort_order/sq_status-asc" + "/skip/" + skip + "/limit/" + limit,
                method: 'GET',
            },
            function (data) {

                resultData.waitingDealFeedback = data.result.data;

                cb();

            }
        )
    }

    F.Serial([
        salesSearch,
        fixInCondition,
        waitingDealFeedbackInfo,
    ], () => {
        RES.successResponse(res, resultData);
    })


}